import Api_user from '../../common/api/user.js'

const state = {
	//专辑列表
	get albumList(){
		return uni.getStorageSync('albumList') || []
	},
	set albumList(value){
		uni.setStorageSync('albumList',value)
	},
}
const mutations = {
	SET_ALBUMLIST(state, payload){
		state.albumList = payload
	}
}
const actions = {
	//专辑列表
	userAlbum({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userAlbum(payload).then(res => {
				const data = res.data.data
				commit('SET_ALBUMLIST',data)
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//我的藏品的专辑
	userAlbums({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userAlbums(payload).then(res => {
				const data = res.data.data
				commit('SET_ALBUMLIST',data)
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//创建专辑
	albumStore({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.albumStore(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//修改专辑
	albumUpdate({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.albumUpdate(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//修改用户
	userUpdate({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userUpdate(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//藏品详情下的列表
	userWorkList({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userWorkList(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//我的藏品列表
	userWorksList({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userWorksList(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//藏品详情
	userWorkShow({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userWorkShow(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//寄售
	userWorkSell({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userWorkSell(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//批量寄售
	userWorkSellBatch({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userWorkSellBatch(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//取消寄售
	userWorkSellCancel({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userWorkSellCancel(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//查找用户基本信息
	searchUser({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.searchUser(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//藏品盲盒列表
	userBoxList({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userBoxList(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//藏品盲盒详情
	userBoxShow({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userBoxShow(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//开启盲盒
	userBoxOpen({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userBoxOpen(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//盲盒挂售列表
	userBoxSellList({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userBoxSellList(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//盲盒挂售
	userBoxSell({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userBoxSell(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//取消盲盒挂售
	userBoxCancel({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.userBoxCancel(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//设置修改优先购
	setPreorder({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.setPreorder(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//领取空投
	airdrop({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.airdrop(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//邀请数量
	inviteCount({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.inviteCount(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
	//邀请列表
	inviteList({ commit }, payload) {
		return new Promise((resolve, reject) => {
			Api_user.inviteList(payload).then(res => {
				resolve(res)
			}).catch(error => {
				reject(error)
			})
		})
	},
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}
